package org.example;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class Mybatisuitl {

    private static SqlSessionFactory Factory=null;
    static {
        String cofing="mybatis.xml";

        try {
            InputStream inputStream= Resources.getResourceAsStream(cofing);
            Factory=new SqlSessionFactoryBuilder().build(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
    public static SqlSession getSeccion()
    {
        SqlSession sqlSession=null;

        if(Factory!=null){
            sqlSession=Factory.openSession();
        }
        return sqlSession;
    }
}
